#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import time
import pytest
from datetime import datetime

# 添加项目根目录到Python路径
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

if __name__ == "__main__":
    # 生成时间戳，用于报告文件名
    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    
    # 设置日志文件路径
    log_file = f"logs/add_banner_test_{timestamp}.log"
    
    # 设置HTML报告路径
    report_file = f"tests/reports/add_banner_test_report_{timestamp}.html"
    
    # 确保日志目录存在
    os.makedirs("logs", exist_ok=True)
    
    # 确保报告目录存在
    os.makedirs("tests/reports", exist_ok=True)
    
    # 运行测试并生成HTML报告
    pytest.main([
        "-v",
        "tests/test_cases/test_add_banner.py",
        f"--html={report_file}",
        "--self-contained-html",
        f"--log-file={log_file}",
        "--log-level=INFO"
    ])
    
    print(f"\n测试完成！")
    print(f"日志文件: {log_file}")
    print(f"HTML报告: {report_file}") 